package com.bawei.mall.cart.domain.req;

import com.bawei.mall.cart.domain.cache.CartCacheKey;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CartInfoReq {


    @NotEmpty(message = "商品ID不可以为空")
    @Min(value = 1, message = "商品ID入参不合法")
    private Long productId;


    @NotEmpty(message = "商品规格不可以为空")
    private String productSku;


    public  static CartInfoReq cartCacheKeyBuild(CartCacheKey cartCacheKey){
        return CartInfoReq.builder()
                .productId(cartCacheKey.getProductId())
                .productSku(cartCacheKey.getProductSku())
                .build();
    }


}
